package com.jwsoft.manager.core.gateway.controller.dataStatistics;

import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.assistant.core.exception.AppException;
import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.dataStatistics.enroll.*;
import com.jwsoft.manager.common.vo.eduAddress.EduAddressQueryVO;
import com.jwsoft.manager.common.vo.eduAddress.EduAddressStatisticsVO;
import com.jwsoft.manager.core.integration.dataStatistics.DyEnrollDataIntegration;
import com.jwsoft.manager.core.integration.dataStatistics.EnrollDataIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 学校统计相关网关
 *
 * @author wangtao
 * @since 2022-11-24
 */
@Slf4j
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "报名数据统计相关", description = "报名数据统计相关")
public class DyEnrollDataController {
    @Autowired
    DyEnrollDataIntegration enrollDataIntegration;

    @PostMapping(value = "/DyEnrollData0001", produces = "application/json;charset=UTF-8")
    @Operation(summary = "获取统筹区内报名过但未被录取的人员清单", description = "获取统筹区内报名过但未被录取的人员清单")
    public AppResponse<PageInfo<NoEnrollStudentVO>> getYwRegistStatistics(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.queryNoEnrollStudent(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0002",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "报名相关数据统计导出", description = "报名相关数据统计导出")
    @NoSignCrypto
    public void downloadData(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downloadData(vo, response);

    }

    @PostMapping(value = "/DyEnrollData0003", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校招生情况统计", description = "学校招生情况统计")
    public AppResponse<PageInfo<EnrollStatisticsVO>> enrollStatistics(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.enrollStatistics(vo));
    }

    @PostMapping(value = "/DyEnrollData0004", produces = "application/json;charset=UTF-8")
    @Operation(summary = "模拟学校招生情况统计", description = "模拟学校招生情况统计")
    public AppResponse<PageInfo<EnrollStatisticsVO>> enrollStatisticsImitate(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.enrollStatisticsImitate(vo));
    }


    @RequestMapping(
            value = "/DyEnrollData0005",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "学校招生情况统计导出", description = "学校招生情况统计导出")
    @NoSignCrypto
    public void downloadEnrollData(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downloadEnrollData(vo, response);

    }

    @RequestMapping(
            value = "/DyEnrollData0006",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "模拟学校招生情况统计", description = "模拟学校招生情况统计")
    @NoSignCrypto
    public void downloadEnrollDataImitate(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downloadEnrollDataImitate(vo, response);

    }


    @PostMapping(value = "/DyEnrollData0007", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校各类情况统计", description = "学校各类情况统计")
    public AppResponse<PageInfo<EnrollStatisticsVO>> allKindStatistic(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.allKindStatistic(vo));
    }

    @PostMapping(value = "/DyEnrollData0008", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校各类情况统计导出", description = "学校各类情况统计导出")
    @NoSignCrypto
    public void downAllKindStatistic(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downAllKindStatistic(vo, response);

    }



    @PostMapping(value = "/DyEnrollData0031", produces = "application/json;charset=UTF-8")
    @Operation(summary = "未被任何一所学校关联(排除服务区)", description = "未被任何一所学校关联(排除服务区)")
    public AppResponse<PageInfo<NoAssociatedAddressVO>> noAssociatedAddress(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.noAssociatedAddress(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0032",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "未被任何一所学校关联(排除服务区)导出", description = "未被任何一所学校关联(排除服务区)导出")
    @NoSignCrypto
    public void downNoAssociatedAddress(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downNoAssociatedAddress(vo, response);

    }

    @PostMapping(value = "/DyEnrollData0033", produces = "application/json;charset=UTF-8")
    @Operation(summary = "同学段学校关联相同地址", description = "同学段学校关联相同地址")
    public AppResponse<PageInfo<SameAddressSchoolVO>> sameAddressSchool(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.sameAddressSchool(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0034",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "同学段学校关联相同地址导出", description = "同学段学校关联相同地址导出")
    @NoSignCrypto
    public void downsameAddressSchool(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downsameAddressSchool(vo, response);

    }

    @PostMapping(value = "/DyEnrollData0035", produces = "application/json;charset=UTF-8")
    @Operation(summary = "同学段学校关联相同地址详情", description = "同学段学校关联相同地址详情")
    public AppResponse<PageInfo<SameAddressSchoolDetailVO>> sameAddressSchoolDetail(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.sameAddressSchoolDetail(vo));
    }

    @PostMapping(value = "/DyEnrollData0045", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校同学段学校关联相同地址详情", description = "学校同学段学校关联相同地址详情")
    public AppResponse<PageInfo<SameAddressSchoolDetailVO>> sameAddressSchoolDetailSchool(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.sameAddressSchoolDetailSchool(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0036",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "同学段学校关联相同地址详情导出", description = "同学段学校关联相同地址详情导出")
    @NoSignCrypto
    public void downsameAddressSchoolDetail(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downsameAddressSchoolDetail(vo, response);

    }


    @PostMapping(value = "/DyEnrollData0037", produces = "application/json;charset=UTF-8")
    @Operation(summary = "同学段服务区关联正学区未关联地址", description = "同学段服务区关联正学区未关联地址")
    public AppResponse<PageInfo<ServerRelationNoSchoolRelataionVO>> serverRelationButNoAssociatedAddress(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.serverRelationButNoAssociatedAddress(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0038",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "同学段服务区关联正学区未关联地址导出", description = "同学段服务区关联正学区未关联地址导出")
    @NoSignCrypto
    public void downserverRelationButNoAssociatedAddress(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downserverRelationButNoAssociatedAddress(vo, response);

    }


    @PostMapping(value = "/DyEnrollData0039", produces = "application/json;charset=UTF-8")
    @Operation(summary = "同学段不同街道学校关联相同地址详情", description = "同学段不同街道学校关联相同地址详情")
    public AppResponse<PageInfo<SameAddressSchoolDetailVO>> sameAddressSchoolStreet(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.sameAddressSchoolStreet(vo));
    }

    @PostMapping(value = "/DyEnrollData0049", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校同学段不同街道学校关联相同地址详情", description = "学校同学段不同街道学校关联相同地址详情")
    public AppResponse<PageInfo<SameAddressSchoolDetailVO>> sameAddressSchoolStreetSchool(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        return AppResponse.successData(enrollDataIntegration.sameAddressSchoolStreetSchool(vo));
    }

    @RequestMapping(
            value = "/DyEnrollData0040",
            method = {RequestMethod.POST, RequestMethod.GET})
    @Operation(summary = "同学段不同街道学校关联相同地址详情导出", description = "同学段不同街道学校关联相同地址详情导出")
    @NoSignCrypto
    public void downsameAddressSchoolStreet(
            HttpServletRequest request,
            @RequestParam Map<String, Object> paramMap,
            @RequestBody(required = false) EnrollStudentQueryVO vo,
            HttpServletResponse response) {

        if (StringUtils.isBlank(vo.getModelCode())) {
            throw new AppException("excel模板编号不能为空");
        }
        enrollDataIntegration.downsameAddressSchoolStreet(vo, response);

    }

    @PostMapping(value = "/DyEnrollData0041", produces = "application/json;charset=UTF-8")
    @Operation(summary = "生成同学段不同街道学校关联相同地址详情", description = "生成同学段不同街道学校关联相同地址详情")
    public AppResponse<PageInfo<SameAddressSchoolDetailVO>> createSameAddressSchoolStreet(
            @RequestBody @Validated EnrollStudentQueryVO vo) {
        enrollDataIntegration.createSameAddressSchoolStreet(vo);
        return AppResponse.successMsg("生成成功！");
    }



}
